//
//  BookingsManager.h
//  mUBB
//
//  Created by Cosmin Stirbu on 3/3/13.
//  Copyright (c) 2013 Cosmin Stirbu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Course.h"
#import "BookingsProtocol.h"
#import "Ticket.h"
#import "Booking.h"
#import <EventKit/EventKit.h>


@interface BookingsManager : NSObject<BookingsProtocol>

// Singleton Instance
+ (BookingsManager *)instance;

// Retrieve Course Bookings
- (Ticket *)getBookingsForCourse:(Course *)course delegate:(id<BookingsProtocol>)delegate;

// Retrieve Bookings of a Room for a given date
- (Ticket *)getBookingsForRoom:(Room *)room withDate:(NSDate *)date delegate:(id<BookingsProtocol>)delegate;

// Create a booking
- (Ticket *)createBooking:(Booking *)booking delegate:(id<BookingsProtocol>)delegate;

// Update a booking
- (Ticket *)updateBooking:(Booking *)booking delegate:(id<BookingsProtocol>)delegate;

// Delete booking
- (Ticket *)deleteBooking:(Booking *)booking delegate:(id<BookingsProtocol>)delegate;

// Group Bookings By Type Of Class
- (NSDictionary *)groupBookingsByTypeOfClass:(NSArray *) bookings;

// Sort Types Of Classes (Ex: Course, Seminar, Lab, Other)
- (NSArray *)sortTypesOfClasses:(NSDictionary *)groupedBookings;

// Returns a bool indicating if the bookings are all in the past or not, or if bookings are already in the calendar
- (BOOL)bookingsStillAvailable:(NSArray *)bookings;

// Returns a bool indicating if an event is already in the Calendar Application
- (BOOL)bookingIsInCalendar:(Booking *)booking;

// Saves EKEvent identifier for Booking
- (void)saveIdentifier:(EKEvent *)event forBooking:(Booking *)booking;

// Adds all the available bookings from the array to the calendar app and returns the number of available bookings. Only ads the ones that aren't allready in the calendar
- (NSInteger)addAllFutureEventsToCalendar:(NSArray *)bookings;

// Creates a string from the booking's study groups
- (NSString *)stringWithBookingStudyGroups:(NSArray *)studyGroups;

// Delete a booking from calendar
- (void)deleteBookingFromCalendar:(Booking *)booking;


@end
